home *** CD-ROM | disk | FTP | other *** search
/ CD Actual Thematic 7: Programming / CDAT7.iso / demos / VisualAge for Java 2.0 Entry / setup / data1.cab / ide-e / IDE / cache / KWHSPT (.txt) < prev    next >
Encoding:
Java Class File  |  1998-09-16  |  1.6 KB  |  65 lines

  1. package java.io;
  2.  
  3. public abstract class Reader {
  4.    protected Object lock;
  5.    private static final int maxSkipBufferSize = 8192;
  6.    private char[] skipBuffer = null;
  7.  
  8.    protected Reader() {
  9.       this.lock = this;
  10.    }
  11.  
  12.    protected Reader(Object lock) {
  13.       this.lock = lock;
  14.    }
  15.  
  16.    public abstract void close() throws IOException;
  17.  
  18.    public void mark(int readAheadLimit) throws IOException {
  19.       throw new IOException("mark() not supported");
  20.    }
  21.  
  22.    public boolean markSupported() {
  23.       return false;
  24.    }
  25.  
  26.    public int read() throws IOException {
  27.       char[] cb = new char[1];
  28.       return this.read(cb, 0, 1) == -1 ? -1 : cb[0];
  29.    }
  30.  
  31.    public int read(char[] cbuf) throws IOException {
  32.       return this.read(cbuf, 0, cbuf.length);
  33.    }
  34.  
  35.    public abstract int read(char[] var1, int var2, int var3) throws IOException;
  36.  
  37.    public boolean ready() throws IOException {
  38.       return false;
  39.    }
  40.  
  41.    public void reset() throws IOException {
  42.       throw new IOException("reset() not supported");
  43.    }
  44.  
  45.    public long skip(long n) throws IOException {
  46.       int nn = (int)Math.min(n, 8192L);
  47.       synchronized(this.lock) {
  48.          if (this.skipBuffer == null || this.skipBuffer.length < nn) {
  49.             this.skipBuffer = new char[nn];
  50.          }
  51.  
  52.          long r;
  53.          int nc;
  54.          for(r = n; r > 0L; r -= (long)nc) {
  55.             nc = this.read(this.skipBuffer, 0, nn);
  56.             if (nc == -1) {
  57.                break;
  58.             }
  59.          }
  60.  
  61.          return n - r;
  62.       }
  63.    }
  64. }
  65.